package com.wpw.java7demo.jvm;

import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;

public class WeakHashMapTest {
	
	public static void main(String[] args) {
		
		WeakHashMap<String, Integer> wMap = new WeakHashMap<>();
		
		wMap.put(String.valueOf(12), 0);
		for (int i = 0; i < 10; i++) {
			wMap.put(String.valueOf(i) , i);
		}
		System.err.println(wMap);
		System.gc();
		System.err.println(wMap);


		System.out.println("===================");
		
		Map<String, Integer> map = new HashMap<>();
		map.put(String.valueOf(12), 0);
		for (int i = 0; i < 10; i++) {
			map.put(String.valueOf(i) , i);
		}
		System.err.println(map);
		System.gc();
		System.err.println(map);
	}

}
